package icegps.com.pingdj.activity;

import android.widget.TextView;

import butterknife.BindView;
import icegps.com.pingdj.R;
import icegps.com.pingdj.bean.LocationStatus;
import icegps.com.pingdj.utils.StringUtils;
import icegps.com.pingdj.utils.UnitUtils;
import icegps.com.pingdj.view.ValueTextView;
import timber.log.Timber;

import static icegps.com.pingdj.map.utils.LatAndLot2Coord.D2R;


/**
 * Created by 111 on 2018/3/16.
 */

public class LocationInfoActivity extends BaseActivity {
    @BindView(R.id.tv_longitude)
    TextView tvLongitude;
    @BindView(R.id.tv_latitude)
    TextView tvLatitude;
    @BindView(R.id.tv_altitude)
    ValueTextView tvAltitude;
    @BindView(R.id.tv_distance)
    ValueTextView tvDistance;
    @BindView(R.id.tv_difference)
    ValueTextView tvDifference;
    @BindView(R.id.tv_azimuth)
    TextView tvAzimuth;
    @BindView(R.id.tv_elevation)
    TextView tvElevation;

    @Override
    protected String setTitle() {
        return getString(R.string.location_info);
    }

    @Override
    protected void init() {
    }


    @Override
    protected int setLayout() {
        return R.layout.activity_location_info;
    }


    @Override
    public void onAnalysisHexLocationData(LocationStatus locationStatus) {
        super.onAnalysisHexLocationData(locationStatus);
        Timber.e(locationStatus.toString());
        tvLatitude.setText(StringUtils.setAccuracy(locationStatus.getLatitude(), 8));

        tvLongitude.setText(StringUtils.setAccuracy(locationStatus.getLongitude(), 8));

        tvAltitude.setText(UnitUtils.HEIGHT, deviceStatus.getHeight(), locationStatus.getAltitude());

        tvElevation.setText(StringUtils.setAccuracy(locationStatus.getElevation(), 3));

        tvDistance.setText(UnitUtils.LENGTH, deviceStatus.getLength(), locationStatus.getDistance());

        tvAzimuth.setText(StringUtils.setAccuracy(locationStatus.getAzimuth(), 3));

        double distance = locationStatus.getDistance();

        double elevation = locationStatus.getElevation();

        double value = distance * Math.sin(elevation * (D2R));

        tvDifference.setText(UnitUtils.HEIGHT, deviceStatus.getHeight(), value);

    }


}
